﻿using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;

namespace BarManager.Core.Entity
{
    [DataContract]
    public abstract class OrdenDetalleBase
    {
        [DataMember]
        public long Id { get; set; }

        [DataMember]
        public Guid Guid { get; set; }

        [Required]
        [DataMember]
        public long OrdenId { get; set; }

        [Required]
        [DataMember]
        public int Cantidad { get; set; }

        [DataMember]
        public int CantidadPagada { get; set; }

        [DataMember]
        public int CantidadRegalada { get; set; }

        [DataMember]
        public int CantidadPorPagar
        {
            get { return Cantidad - CantidadPagada - CantidadRegalada;}
        }

        [Required]
        [DataMember]
        public DateTime FechaPedido { get; set; }

        [DataMember]
        public DateTime? FechaEntrega { get; set; }

        [DataMember]
        public EstadoDetalle Estado { get; set; }

        [DataMember]
        public abstract decimal Precio { get; }

        [DataMember]
        public abstract decimal SubTotalPagado { get; }

        [DataMember]
        public abstract decimal SubTotalPorPagar { get; }

        [DataMember]
        public abstract decimal SubTotal { get; }

        [DataMember]
        public decimal SubTotalRegalos
        {
            get { return CantidadRegalada * Precio; }
        }

        public virtual Orden Orden { get; set; }

        public OrdenDetalleBase()
        {
            Guid = Guid.NewGuid();
        }
    }

    public enum EstadoDetalle : short
    {
        Pendiente = 1,
        Cocina = 2,
        ParaEntrega = 3,
        Entregado = 4,
        Cancelado = 5
    }
}
